GLSL compiler messages from different vendors [on hold]
Posted
by
revers
on Game Development
See other posts from Game Development
or by revers
Published on 2013-11-07T11:01:12Z
Indexed on
2013/11/07
16:14 UTC
Read the original article
Hit count: 316
I'm writing a GLSL shader editor and I want to parse GLSL compiler messages to make hyperlinks to invalid lines in a shader code. I know that these messages are vendor specific but currently I have access only to AMD's video cards. I want to handle at least NVidia's and Intel's hardware, apart from AMD's.
If you have video card from different vendor than AMD, could you please give me the output of following C++ program:
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>
using namespace std;
#define STRINGIFY(X) #X
static const char* fs = STRINGIFY(
out vec4 out_Color;
mat4 m;
void main() {
vec3 v3 = vec3(1.0);
vec2 v2 = v3;
out_Color = vec4(5.0 * v2.x, 1.0);
vec3 k = 3.0;
float = 5;
}
);
static const char* vs = STRINGIFY(
in vec3 in_Position;
void main() {
vec3 v(5);
gl_Position = vec4(in_Position, 1.0);
}
);
void printShaderInfoLog(GLint shader) {
int infoLogLen = 0;
int charsWritten = 0;
GLchar *infoLog;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLen);
if (infoLogLen > 0) {
infoLog = new GLchar[infoLogLen];
glGetShaderInfoLog(shader, infoLogLen, &charsWritten, infoLog);
cout << "Log:\n" << infoLog << endl;
delete [] infoLog;
}
}
void printProgramInfoLog(GLint program) {
int infoLogLen = 0;
int charsWritten = 0;
GLchar *infoLog;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLen);
if (infoLogLen > 0) {
infoLog = new GLchar[infoLogLen];
glGetProgramInfoLog(program, infoLogLen, &charsWritten, infoLog);
cout << "Program log:\n" << infoLog << endl;
delete [] infoLog;
}
}
void initShaders() {
GLuint v = glCreateShader(GL_VERTEX_SHADER);
GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
GLint vlen = strlen(vs);
GLint flen = strlen(fs);
glShaderSource(v, 1, &vs, &vlen);
glShaderSource(f, 1, &fs, &flen);
GLint compiled;
glCompileShader(v);
bool succ = true;
glGetShaderiv(v, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
cout << "Vertex shader not compiled." << endl;
succ = false;
}
printShaderInfoLog(v);
glCompileShader(f);
glGetShaderiv(f, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
cout << "Fragment shader not compiled." << endl;
succ = false;
}
printShaderInfoLog(f);
GLuint p = glCreateProgram();
glAttachShader(p, v);
glAttachShader(p, f);
glLinkProgram(p);
glUseProgram(p);
printProgramInfoLog(p);
if (!succ) {
exit(-1);
}
delete [] vs;
delete [] fs;
}
int main(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(600, 600);
glutCreateWindow("Triangle Test");
glewInit();
GLenum err = glewInit();
if (GLEW_OK != err) {
cout << "glewInit failed, aborting." << endl;
exit(1);
}
cout << "Using GLEW " << glewGetString(GLEW_VERSION) << endl;
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* version = glGetString(GL_VERSION);
const GLubyte* glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
GLint major, minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
cout << "GL Vendor : " << vendor << endl;
cout << "GL Renderer : " << renderer << endl;
cout << "GL Version : " << version << endl;
cout << "GL Version : " << major << "." << minor << endl;
cout << "GLSL Version : " << glslVersion << endl;
initShaders();
return 0;
}
On my video card it gives:
Status: Using GLEW 1.7.0
GL Vendor : ATI Technologies Inc.
GL Renderer : ATI Radeon HD 4250
GL Version : 3.3.11631 Compatibility Profile Context
GL Version : 3.3
GLSL Version : 3.30
Vertex shader not compiled.
Log:
Vertex shader failed to compile with the following errors:
ERROR: 0:1: error(#132) Syntax error: '5' parse error
ERROR: error(#273) 1 compilation errors. No code generated
Fragment shader not compiled.
Log:
Fragment shader failed to compile with the following errors:
WARNING: 0:1: warning(#402) Implicit truncation of vector from size 3 to size 2.
ERROR: 0:1: error(#174) Not enough data provided for construction constructor
WARNING: 0:1: warning(#402) Implicit truncation of vector from size 1 to size 3.
ERROR: 0:1: error(#132) Syntax error: '=' parse error
ERROR: error(#273) 2 compilation errors. No code generated
Program log:
Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.
Or if you like, you could give me other compiler messages than proposed by me.
To summarize, the question is:
What are GLSL compiler messages formats (INFOs, WARNINGs, ERRORs) for different vendors? Please give me examples or pattern explanation.
EDIT: Ok, it seems that this question is too broad, then shortly:
How does NVidia's and Intel's GLSL compilers present ERROR and WARNING messages?
AMD/ATI uses patterns like this:
ERROR: <position>:<line_number>: <message>
WARNING: <position>:<line_number>: <message>
(examples are above).
© Game Development or respective owner